if(console == undefined){
	var console = {};
	console.log = function(){
		return;
	}
}
var propertyCount = function(obj){
	if (typeof obj == 'object') {
		var result = 0;
		for (property in obj) {
			result++;
		}
		return result;
	} else 
		return false;
}


Ext.ns('Ext.ux.Desktop.CustomMenu');


Ext.ux.Desktop.CustomMenu.Add = Ext.extend(Ext.menu.Item, {
	link: null,
	text: 'Add',
	initComponent : function(){
		
		//console.log(this.link.stateManager.getAllDeletedIcons());
		var basicItems = [];
		var DI = this.link.stateManager.getAllDeletedIcons();
		
		for(var i in DI)
			if(DI[i])
				basicItems.push({value: DI[i].id, text: DI[i].text});
		
		Ext.apply(this, {
			
			menu: new Ext.menu.Menu({
				items: basicItems,
				listeners: {
					scope: this,
					itemclick : function(item, e){
						
						this.link.ShowIcon(item);
					}
				}
			})
		});
		Ext.ux.Desktop.CustomMenu.Add.superclass.initComponent.call(this);
	}
});

Ext.ux.Desktop.CustomMenu.Delete = Ext.extend(Ext.menu.Item, {
	link: null,
	text: 'Delete',
	initComponent : function(){
		
		Ext.apply(this, {
			handler : function(){
				this.link.HideIcon();
			}
		});
		Ext.ux.Desktop.CustomMenu.Delete.superclass.initComponent.call(this);
	}
});

Ext.ux.Desktop.CustomMenu.SortIcons = Ext.extend(Ext.menu.Item, {
	link: null,
	text: 'Sort Icons',	
	initComponent : function(){
		
		Ext.apply(this, {
			handler : function(c){
				this.link.SetIconsSortable(true);
			}
		});
		Ext.ux.Desktop.CustomMenu.SortIcons.superclass.initComponent.call(this);
	}
});